package main

import (
	"fmt"
)

// BaseWare 一些基础的属性
type BaseWare struct {
	deviceNum string //设备号
	core      string //内核
	phone     Phone  //手机
	laptop    Laptop //笔记本
}

type Phone struct {
	PhoneNum string //手机号
}

type Laptop struct {
	deviceType string //设备类型
}

type FactoryApi interface {
	//Create 创建函数
	Create()
}

func (p *Phone) Create() {
	fmt.Println(p.PhoneNum)
}

func (p *Laptop) Create() {
	fmt.Println(p.deviceType)
}

func Create(typ string) BaseWare {
	switch typ {
	case "phone":
		return BaseWare{phone: Phone{PhoneNum: "123"}}
	case "lap":
		return BaseWare{laptop: Laptop{deviceType: "c1c2c3"}}
	}
	return BaseWare{}
}

func main() {
	p := Create("phone")
	fmt.Printf("第1个打印:%s", p.phone.PhoneNum)
	l := Create("laptop")
	fmt.Printf("第2个打印:%s", l.laptop.deviceType)
	l = Create("lap")
	fmt.Printf("第3个打印:%s", l.laptop.deviceType)
}
